package com.czh.system.controller.auth;

import com.czh.common.domain.AjaxRes;
import com.czh.framework.security.web.service.AuthService;
import com.czh.service.entity.dto.LoginUserDto;
import com.czh.service.entity.dto.MailLoginDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Deprecated
public class LogInController {

    @Autowired
    AuthService loginService;

    @PostMapping("login")
    public AjaxRes login(@RequestBody LoginUserDto loginUserDto) {
        String token = loginService.login(loginUserDto);

        AjaxRes success = AjaxRes.success();
        success.put(AjaxRes.KEY_TOKEN,token);
        return success;
    }

    @PostMapping("sendMail")
    public AjaxRes sendMail(String mail) {
        AjaxRes ajaxRes = loginService.mailLogin(mail);
        return ajaxRes;
    }

    @PostMapping("mailLogin")
    public AjaxRes mailLogin(@RequestBody MailLoginDto mailLoginDto) {
      return loginService.authenticateMailCode(mailLoginDto);
    }

}
